import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * Class that describe the Encoder process of our solution.
 * Provide to read the input file given as initial problem,with a number of edge with
 * respective starting vertex and ending vertex.
 * After having stored the content of the file(where the name is passed as inputFileName parameter).
 * Then provide to store this content in a correct graph Format G=(V,E).
 * 
 * @author Scinetti,Trombini,Garcia Fernandez
 *
 */

public class Encoder {

    private Graph G = new Graph();
	public Encoder(final String inputFileName) throws IOException {

		
			FileReader input = new FileReader(Main.PATH + inputFileName);
			BufferedReader br = new BufferedReader(input);
			String line;

			while ((line = br.readLine()) != null) {
				if (Character.isDigit(line.charAt(0))) {
					String[] split = line.split(",");
					this.G.addEdge(split[1], split[2]);				
				}
			}
			
			this.G.extractVertex();
	}

    /**
     * method that retrieve the graph created
     * @return
     */

	public Graph getGraph(){
		return G;
	}
	
}
